import './App.less';
import {Redirect, Route,Switch} from 'react-router-dom'
import Login from './views/Login/index';
import NotFound from './views/NotFound';
import Main from './Layout';
import {connect} from 'react-redux'
// let isLogin = true  //模拟登录状态
function App(props) {
  return (
    <div className="App">
      <Switch>
        <Route path="/admin" render={()=>{
          if(props.user.isLogin){
            return <Main/>
          }else{
            return <Redirect to="/login"/>
          }
        }}/>
        <Redirect path="/" exact to="/admin"/>
        <Route path="/login" component={Login}/>
        <Route path="*" component={NotFound}/>
      </Switch>
    </div>
  );
}

export default connect(({user})=>({user}))(App)
